package com.gyy.Thermometry;

import com.gyy.sdk.HCNetSDK;
import com.sun.jna.Pointer;

import java.io.UnsupportedEncodingException;

/**
 *
 * @Author sdk支持
 * @Date 2021/3/16 17:54
 */
public class ThermometryPresetInfo {

    static HCNetSDK hCNetSDK = HCNetSDK.INSTANCE;

    /**
     * 测试获取专家测温配置参数
     *
     * @param lUserID 用户登录句柄
     * @param iChannelNum 通道号
     */
    public void getExpertModeTemperatureCfg(int lUserID, int iChannelNum) throws UnsupportedEncodingException {

        HCNetSDK.BYTE_ARRAY pStatus = new HCNetSDK.BYTE_ARRAY(16 * 1024);
        Pointer pStatusBuffer = pStatus.getPointer();
        HCNetSDK.NET_DVR_STD_CONFIG m_lpConfigParam = new HCNetSDK.NET_DVR_STD_CONFIG();
        HCNetSDK.NET_DVR_THERMOMETRY_COND m_lpThCond = new HCNetSDK.NET_DVR_THERMOMETRY_COND();
        HCNetSDK.NET_DVR_THERMOMETRY_PRESETINFO m_lpThPresetInfp = new HCNetSDK.NET_DVR_THERMOMETRY_PRESETINFO();
        m_lpThCond.dwSize = m_lpThCond.size();
        m_lpThCond.dwChannel = iChannelNum;
        m_lpThCond.wPresetNo = 1;
        m_lpThCond.write();
        m_lpConfigParam.lpCondBuffer = m_lpThCond.getPointer();
        m_lpConfigParam.dwCondSize = m_lpThCond.dwSize;
        m_lpConfigParam.lpInBuffer = null;
        m_lpConfigParam.dwInSize = 0;
        m_lpConfigParam.lpOutBuffer = m_lpThPresetInfp.getPointer();
        m_lpConfigParam.dwOutSize = m_lpThPresetInfp.size();
        m_lpConfigParam.lpStatusBuffer = pStatusBuffer;
        m_lpConfigParam.dwStatusSize = 16 * 1024;
        m_lpConfigParam.byDataType = 0;
        m_lpThPresetInfp.write();
        m_lpConfigParam.write();
        boolean bRet = hCNetSDK.NET_DVR_GetSTDConfig(lUserID, 3624, m_lpConfigParam);
        if (bRet == false) {
            System.out.println("预置点参数获取失败！！! 错误码：" + hCNetSDK.NET_DVR_GetLastError());
        } else
            m_lpThPresetInfp.read();
            System.out.println("预置点参数获取成功!预置点1：" + m_lpThPresetInfp.wPresetNo
                    + "，使能：" + m_lpThPresetInfp.struPresetInfo[0].byEnabled
                    + ",规则ID：" + m_lpThPresetInfp.struPresetInfo[0].byRuleID
                    + ",距离：" + m_lpThPresetInfp.struPresetInfo[0].wDistance
                    + ",发射率：" + m_lpThPresetInfp.struPresetInfo[0].fEmissivity
                    + ",距离单位：" + m_lpThPresetInfp.struPresetInfo[0].byDistanceUnit
                    + ",反射温度使能：" + m_lpThPresetInfp.struPresetInfo[0].byReflectiveEnabled
                    + ",反射温度：" + m_lpThPresetInfp.struPresetInfo[0].fReflectiveTemperature
                    + ",规则名称：" + new String(m_lpThPresetInfp.struPresetInfo[0].szRuleName , "GBK")
                    + ",规则标定类型：" + m_lpThPresetInfp.struPresetInfo[0].byRuleCalibType
                    + ",点测温坐标：（" + m_lpThPresetInfp.struPresetInfo[0].struPoint.fX + "," + m_lpThPresetInfp.struPresetInfo[0].struPoint.fY + ")");
    }
}
